import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { User } from './user.entity';

@Entity()
export class Logs {
  constructor(
    id: number,
    date: Date,
    ip: string,
    method: string,
    url: string,
    statusCode: number,
    responseTime: number,

    user: User,
  ) {
    this.id = id;
    this.date = date;
    this.ip = ip;
    this.method = method;
    this.url = url;
    this.statusCode = statusCode;
    this.responseTime = responseTime;
    this.user = user || null;
  }
  @PrimaryGeneratedColumn()
  id: number;

  //   @Column()
  //   userId: number;

  @Column()
  date: Date;

  @Column()
  ip: string;

  @Column()
  method: string;

  @Column()
  url: string;

  @Column()
  statusCode: number;

  @Column()
  responseTime: number;

  @ManyToOne(() => User, (user) => user.logs)
  @JoinColumn()
  user: User;
}
